<style type="text/css">
.field{
    border:#B58105 1px solid;
    height: 40px;
    line-height: 40px
} 
.field .yellow{
    background-color: #FFF8DB;
    color: #B58105;

}
.layui-form-item .layui-input{ width: 500px!important; }
</style>

<form  class="layui-form layui-card" action="{:request()->url()}" data-auto="true" method="post" autocomplete="off">
    <div class="layui-card-body">
<div class="layui-form-item" style="width: 600px;margin: 0 auto;">
        <h3 class="font-w7 margin-left-20">你正在进行敏感操作，继续操作前请验证您的身份</h3>
        <div class="field  margin-left-20">
        <div class="ui message yellow">
        &nbsp;&nbsp;更换号码后，你将无法通过 「原手机号码+密码」 登录
        </div>
        </div>
</div>

<div class="layui-form-item" style="width: 600px;margin: 0 auto;">
        {if $userinfo['db1']['phone']}
     <div class="layui-form-item">
            <label class="layui-form-label label-required">原手机号码</label>
            <div class="layui-input-block">
                <input name="old_phone" value='{$userinfo["db1"]["phone"]|default=""}' disabled  class="layui-input">

            </div>
        </div>
        {/if}
        <div class="layui-form-item margin-top-20">
            <label class="layui-form-label label-required">新手机号</label>
            <div class="layui-input-block">
                <input name="new_phone" value='{$vo.nickname|default=""}' required placeholder="请输入需要绑定的手机号" class="layui-input">
                    <button id="send-code-button"  data-title="修改手机号码" type="button" class="layui-btn layui-btn-normal margin-top-20">发送验证码</button>
            </div>
        </div>
        <div class="layui-form-item margin-top-20">
            <label class="layui-form-label label-required">验证码</label>
            <div class="layui-input-block">
                <input name="yz_code" value='{$vo.user_type|default=""}' required placeholder="请输入验证码" class="layui-input">
            </div>
        </div>

    <div class="hr-line-dashed"></div>
    {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}

    <div class="layui-form-item text-center">
        <button class="layui-btn" type='submit'>确认</button>
        <button class="layui-btn layui-btn-danger" type='button' data-close>取消</button>
    </div>
</div>
</div>
    <script>window.form.render();</script>


<script type="text/javascript">
        var seconds = 15;


        $("#send-code-button").click(function() {
        if($('#send-code-button').text()!="发送验证码"){return}
        var phone_number = $("input[name='new_phone']").val()
        $("input[name='new_phone']").attr('disabled',true)

        postData = {};
        postData['new_phone'] = phone_number
        // $(data).each(function(i) {
        //     postData[this.name]= this.value;
        // });
        // postData['create_at']=create_at;
        console.log(postData);
        // 将获取到的数据post给服务器
        url = SCOPE.send_url;
        $.post(url, postData, function(result) {
            if (result.code == 1) {
                //成功
                var interval_send = setInterval(function(){
                          seconds = seconds-1
                          $('#send-code-button').text(s)
                          if(seconds == 0){
                               $('#send-code-button').text('发送验证码')
                               clearInterval(interval_send);
                            }
                      },1000)

                layer.open({
                    content: result.info,
                    icon: 1,
                    title: '成功提示'
                });
                //return dialog.success(result.info);
            } else if (result.code == 0) {
                $("input[name='new_phone']").attr('disabled',false)
                // 失败
                layer.open({
                    content: result.info,
                    icon: 2,
                    title: '错误提示'
                });
                //return dialog.error(result.info);
            }
        }, "JSON");
    });


        var SCOPE = {
        'send_url' : "{:url('send_code')}",
    };
</script>
</form>